<?php
namespace App\Event\UserPay;

use App\Event\Event;
use App\Repository\UserRepository;
use App\Repository\LevelRepository;

// 支付成功事件
class StatusOkEvent extends Event
{
    public $pay;
    
    public $money;
    
    public $user;
    
    public $level;
    
    public $repeat;
    
    // 用户及金额
    public function __construct($pay)
    {
        $this->pay  = $pay;
        $this->money = $pay->money;
        $this->user = UserRepository::make($this->pay->user);
        $this->level = LevelRepository::make($this->user->level);
        
        // 用户是否为复投
        $this->repeat = $this->user->moneyAllHas($this->config('money_pay'));
    }
}